<?php

namespace app\common\model;

use think\Model;

class Feedback extends Model
{
    protected $autoWriteTimestamp = true;

    public function feedback()
    {
        $param = request()->param();
        $data = $param['data'];
        $userId = request()->userId;
        $res = self::create([
            'from_id' => $userId,
            'data' => $data,
            'to_id' => 0
        ]);
        if(!$res) TApiException();
        return true;
    }
    public function feedbacklist()
    {
        $param = request()->param();
        $page = $param['page'];
        $userId = request()->userId;
        $list = $this->where(['from_id'=>$userId])->whereOr('to_id',$userId)->page($page,10)->select();
        return $list;
    }
}
